package leetcode.list;

import java.util.LinkedList;

public class Lc234 {

    public boolean isPalindrome(ListNode head) {
        ListNode origin = head;
        LinkedList<ListNode> stack = new LinkedList<>();
        while (head != null) {
            stack.push(head);
            head = head.next;
        }
        while (!stack.isEmpty()) {
            if (stack.pop().val != origin.val) return false;
            origin = origin.next;
        }
        return true;
    }

}
